﻿#ifndef __DAHUA_GENICAM_ICAMERA_H__
#define __DAHUA_GENICAM_ICAMERA_H__

#include "Defs.h"
#include "Frame.h"
#include "Memory/SharedPtr.h"
#include "StreamSource.h"

GENICAM_NAMESPACE_BEGIN

/// \~chinese
/// \brief 鐩告満瀵硅薄鎺ュ彛绫?
/// \defgroup Camera 鐩告満鍏辩敤鎿崭綔鎺ュ彛
/// @{
/// \~english
/// \brief Camera Object Interface Class
/// \defgroup Camera Camera's Common Operation Interface
/// @{

/// \~chinese
/// \brief Class ICamera 鐩告満瀵硅薄鎺ュ彛绫伙紝琛ㄧず涓€鍙扮浉链猴紝镓€链夊岗璁被鍨嬮兘鍙叡鐢ㄧ殑鎺ュ彛銆傝瀹炰緥瀵硅薄鍙€氲绷CSystem銮峰彇
/// \~english
/// \brief Class ICamera Camera Object Interface Class, it means a common interface for all protocol type; This instance object can be got by CSystem 
class GENICAM_API ICamera
{
protected:
	/// \~chinese
	/// \brief 鏋愭瀯鍑芥暟
	/// \~english
	/// \brief destruct function
	virtual ~ICamera(){}
	
public:

	enum ECameraAccessPermission
	{
		accessPermissionOpen = 0,		///< \~chinese GigE鐩告満娌℃湁琚繛鎺?       ///< \~english The GigE vision device isn't connected to any application. 
		accessPermissionExclusive, 	///< \~chinese 镫崰璁块棶鏉冮檺        ///< \~english Exclusive Access Permission   
		accessPermissionControl, 	///< \~chinese 闱炵嫭鍗犲彲璇昏闂潈闄? ///< \~english Non-Exclusive Readbale Access Permission  
		accessPermissionControlWithSwitchover,  	///< \~chinese Control access with switchover enabled.        ///< \~english Control access with switchover enabled.	
		accessPermissionUnknown = 254,  	///< \~chinese 镞犳硶纭畾        ///< \~english Value not known; indeterminate.   	
		accessPermissionUndefined     	///< \~chinese 链畾涔夎闂潈闄?     ///< \~english Undefined Access Permission
	};

	enum ECameraType
	{
		typeGige = 0,	    ///< \~chinese GIGE鐩告満       ///< \~english GigE Vision Camera
		typeU3v = 1,	    ///< \~chinese USB3.0鐩告満     ///< \~english USB3.0 Vision Camera
        typeCL = 2,		    ///< \~chinese CAMERALINK 鐩告満///< \~english Cameralink camera
        typePCIe = 3,       ///< \~chinese PCIe鐩告満       ///< \~english PCIe Camera
		typeUndefined = 255	///< \~chinese 链煡绫诲瀷       ///< \~english Undefined Camera
	};
	
	/// \~chinese
	/// \brief  寰楀埌鐩告満绫诲瀷
	/// \return 杩斿洖鐩告満绫诲瀷
	/// \~english
	/// \brief  get Camera Type
	/// \return Success: Camera Type, Failure:typeUndefined
	virtual int32_t getType() const = 0;
	
	/// \~chinese
	/// \brief  銮峰彇鐩告満鍚岖О
	/// \return 杩斿洖鐩告満鍚岖О
	/// \~english
	/// \brief  get Camera Name
	/// \return Success:Camera Name, Failure:NULL
	virtual const char * getName() = 0;
	
	/// \~chinese
	/// \brief  銮峰彇鐩告満镄勫敮涓€镙囱瘑.
	/// \return 鍞竴镙囱瘑鐩告満镄勫瓧绗︿覆.
	/// \~english
	/// \brief  get Camera Unique Indentification
	/// \return Success:Identification (Key), Failure:NULL
	virtual const char * getKey()  = 0;
	
    /// \~chinese
	/// \brief  杩炴帴璁惧
	/// 涓庣浉链哄缓绔嬭繛鎺ュ叧绯伙紝濡侴ige Vision鍗忚镄勭浉链哄嵆鏄幏寰楁带鍒舵潈闄愩€佸垱寤烘带鍒堕€氶亾
	/// \param [in] accessPermission 镓揿紑鐩告満鎺у埗阃氶亾镞堕粯璁や负control access 鏉冮檺
	/// \return 鏄惁杩炴帴鎴愬姛
	/// \~english
	/// \brief  connect to camera
	/// get the control permission of camera, and create the control channel
	/// \param [in] accessPermission Control access permission is default when open the control channel of the camera
	/// \retval false connection failed
	/// \retval true  connection successful
	virtual bool connect(ECameraAccessPermission accessPermission = accessPermissionControl) = 0;
		
	/// \~chinese
	/// \brief 鏂紑杩炴帴
	/// 鏂紑涓庣浉链虹殑杩炴帴鍏崇郴锛屽Gige Vision鍗忚镄勭浉链哄嵆鏄喷鏀炬带鍒舵潈闄愩€侀攒姣佹带鍒堕€氶亾
	/// \return 鏄惁鏂紑鎴愬姛 
	/// \~english
	/// \brief disconnect camera
	/// release the control permission of camera, and withdraw the control channel
	/// \retval false disconnection failed
	/// \retval true  disconnection successful
	virtual bool disConnect() = 0;
		
	/// \~chinese
	/// \brief 鍒ゆ柇鐩告満褰揿墠鏄惁澶勪簬宸茶繛鎺ョ姸镐?
	/// \return 鏄惁宸茶繛鎺?
	/// \~english
	/// \brief check the camera is connected or disconnected
	/// \retval false camera is disconnected
	/// \retval true  camera is connected
	virtual bool isConnected() = 0;
		      								
	/// \~chinese
	/// \brief  銮峰彇鐩告満镓€灞炵殑鎺ュ彛鍚?
	/// \return 璁惧镓€灞炵殑鎺ュ彛鍚?
	/// \~english
	/// \brief  get the name of interface which is used for connecting the camera
	/// \return Success:Interface Name, Failure:NULL
	virtual const char * getInterfaceName()  = 0;

	/// \~chinese
	/// \brief  銮峰彇鐩告満镓€杩炴帴镄勬帴鍙ｇ被鍨?
	/// \return 鐩告満镓€杩炴帴镄勬帴鍙ｇ被鍨?
	/// \~english
	/// \brief  get the type of interface which is used for connecting the camera
	/// \return the type of interface
	virtual int32_t getInterfaceType() const = 0;
	
	/// \~chinese
	/// \brief 涓嬭浇鐩告満鎻忚堪XML鏂囦欢
	/// 涓嬭浇鐩告満鎻忚堪鏂囦欢锛屽苟淇濆瓨鍒版寚瀹氲矾寰?
	/// \param [in] aFullFilename 鏂囦欢瑕佷缭瀛樼殑璺缎
	/// \return 鏄惁涓嬭浇鎴愬姛
	/// \~english
	/// \brief download camera description XML file
	/// download camera description files, and save the files to specified path
	/// \param [in] aFullFilename The full paths where the downloaded XMl files would be saved to
	/// \retval false download failed
	/// \retval true  download successful
	virtual bool downLoadGenICamXML(const char* aFullFilename) = 0;

	/// \~chinese
	/// \brief 璇荤敤鎴疯嚜瀹氢箟鏁版嵁銆傜浉链哄唴閮ㄤ缭鐣?2768瀛楄妭鐢ㄤ簬鐢ㄦ埛瀛桦偍镊畾涔夋暟鎹纸姝ゅ姛鑳介拡瀵规湰鍝佺墝鐩告満锛屽叾瀹冨搧鐗岀浉链烘棤姝ゅ姛鑳斤级銆?
	/// \param [out] pBuffer 鏁版嵁缂揿啿镄勬寚阍堛€?
	/// \param [in] dwCount 链熸湜璇诲嚭镄勫瓧鑺傛暟
	/// \return 杩斿洖鐢ㄦ埛瀹为台璇诲彇鍒扮殑瀛楄妭鏁?
	/// \~english read user-defined data; Inside the camera, there are 32768 bytes reserved for user to store private data (Only our own camera has this function)
	/// \param [out] pBuffer pointer of the data buffer
	/// \param [in]  dwCount byte count expected
	/// \return return byte count read in fact
	virtual size_t readUserPrivateData(void* pBuffer, size_t dwCount) = 0;
	
	/// \~chinese
	/// \brief 鍐欑敤鎴疯嚜瀹氢箟鏁版嵁銆傚拰readUserPrivateData瀵瑰簲
	/// \param [in] pBuffer 鏁版嵁缂揿啿镄勬寚阍堛€?
	/// \param [in] dwCount 链熸湜鍐椤叆镄勫瓧鑺傛暟
	/// \return 杩斿洖鐢ㄦ埛瀹为台鍐椤叆镄勫瓧鑺傛暟
	/// \~english write user-defined data; Inside the camera, there are 32768 bytes reserved for user to store private data (Only our own camera has this function)
	/// \param [out] pBuffer pointer of the data buffer
	/// \param [in]  dwCount byte count expected
	/// \return return byte count written in fact
	virtual size_t writeUserPrivateData(const void *pBuffer, size_t dwCount) = 0;
	
	/// \~chinese
	/// \brief 銮峰彇鐩告満鍒堕€犲巶鍟嗗悕绉?
	/// \return 杩斿洖鐩告満鍒堕€犲巶鍟嗗悕绉?
	/// \~english
	/// \brief get the vendor name of this camera
	/// \return camera's vendor, return NULL if failed
	virtual const char * getVendorName() = 0;
	
	/// \~chinese
	/// \brief 銮峰彇鐩告満鍨嫔佛
	/// \return 杩斿洖鐩告満鍨嫔佛
	/// \~english
	/// \brief get the model name of this camera 
	/// \return camera's model name, return NULL if failed
	virtual const char * getModelName() = 0;

	/// \~chinese
	/// \brief 銮峰彇鐩告満搴忓垪鍙?
	/// \return 杩斿洖鐩告満搴忓垪鍙?
	/// \~english
	/// \brief get serial number of this camera
	/// \return camera's serial number, return NULL if failed
	virtual const char * getSerialNumber() = 0;

	/// \~chinese
	/// \brief 銮峰彇鐩告満锲轰欢鐗堟湰鍙?
	/// \return 杩斿洖鐩告満锲轰欢鐗堟湰鍙?
	/// \~english
	/// \brief get device version of this camera
	/// \return camera's device version, return NULL if failed
	virtual const char * getDeviceVersion() = 0;

	/// \~chinese
	/// \brief 寰€鐩告満涓插彛瀵勫瓨鍣ㄥ啓鏁版嵁锛屾疮娆″啓浼氭竻闄ゆ帀涓婃镄勬暟鎹纸姝ゅ姛鑳藉彧鏀寔鍖呭惈涓插彛锷熻兘镄勬湰鍝佺墝鐩告満 锛?
	/// \param [in] pBuffer 鏁版嵁缂揿啿镄勬寚阍堛€?
	/// \param [in] dwCount 链熸湜鍐椤叆镄勫瓧鑺傛暟
	/// \return 杩斿洖鐢ㄦ埛瀹为台鍐椤叆镄勫瓧鑺傛暟
	/// \~english write serial data to camera serial register, will erase the data writen before (Only our own camera with Serial Port has this function)
	/// \param [in] pBuffer pointer of the data buffer
	/// \param [in]  dwCount byte count expected
	/// \return return byte count written in fact
	virtual size_t writeUARTData(const void* pBuffer, size_t dwCount) = 0;

	/// \~chinese
	/// \brief 浠庣浉链轰覆鍙ｅ瘎瀛桦櫒璇诲彇涓插彛鏁版嵁锛堟锷熻兘鍙敮鎸佸寘鍚覆鍙ｅ姛鑳界殑链搧鐗岀浉链?锛?
	/// \param [out] pBuffer 鏁版嵁缂揿啿镄勬寚阍堛€?
	/// \param [in] dwCount 链熸湜璇诲嚭镄勫瓧鑺傛暟
	/// \return 杩斿洖鐢ㄦ埛瀹为台璇诲彇鍒扮殑瀛楄妭鏁?
	/// \~english read serial data from camera serial register (Only our own camera with Serial Port has this function)
	/// \param [out] pBuffer pointer of the data buffer
	/// \param [in]  dwCount byte count expected
	/// \return return byte count read in fact
	virtual size_t readUARTData(void* pBuffer, size_t dwCount) = 0;

    /// \~chinese
    /// \brief 銮峰彇鐩告満鍒堕€犱俊鎭?
    /// \return 杩斿洖鐩告満鍒堕€犱俊鎭紝澶辫触锛氲繑锲濶ULL
    /// \~english
    /// \brief get manufacture info of this camera
    /// \return camera's manufacture info, return NULL if failed
    virtual const char * getManufactureInfo() = 0;
};

typedef Memory::TSharedPtr<ICamera> ICameraPtr;
/// @}

GENICAM_NAMESPACE_END

#endif//__DAHUA_GENICAM_ICAMERA_H__
